#include "Core/Array/Queue.h"
#include "QueueTest.h"

#include <iostream>

const char * QueueTest::GetName() const
{
	return "Queue Test";
}

error QueueTest::Create()
{
	if(Failed(UnitTest::Create()))
		return errFailed;

	return errOK;
}

error QueueTest::Destroy()
{
	if(Failed(UnitTest::Destroy()))
		return errFailed;

	return errOK;
}

error QueueTest::Execute()
{
	Queue<int> queue;
	queue.Enqueue(4);
	queue.Enqueue(8);
	queue.Enqueue(6);
	queue.Enqueue(0);
	queue.Enqueue(-8);

	if(queue.Size()!=5)
		return errFailed;

	int val = queue.Dequeue();

	if(val!=4)
		return errFailed;

	if(queue.Size()!=4)
		return errFailed;

	val = queue.Dequeue();

	if(val!=8)
		return errFailed;

	if(queue.Size()!=3)
		return errFailed;

	val = queue.Dequeue();

	if(val!=6)
		return errFailed;

	if(queue.Size()!=2)
		return errFailed;

	val = queue.Dequeue();

	if(val!=0)
		return errFailed;

	if(queue.Size()!=1)
		return errFailed;

	val = queue.Dequeue();

	if(val!=-8)
		return errFailed;

	if(queue.Size()!=0)
		return errFailed;

	for(int i=0; i<100; i++)
		queue.Enqueue(i);

	for(int i=0; i<78; i++)
		queue.Dequeue();

	for(int i=0; i<1000; i++)
		queue.Enqueue(i);

	return errOK;
}
